package com.naiterui.ehp.bs.cms.modules.devops.feign;

import java.util.List;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import com.naiterui.ehp.bp.support.config.FeignConfiguration;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.cms.modules.devops.vo.ScheduleJobVO;

/**
 * 定时任务feign
 * 
 * @author yangfuya
 * @since 2022/4/1
 */
@FeignClient(name = "schedule", url = "${ehp.domain.schedule}", configuration = FeignConfiguration.class)
public interface ScheduleFeign {

    /**
     * 定时任务列表
     * 
     * @return
     * @throws BusinessException
     */
    @PostMapping("job/list")
    List<ScheduleJobVO> listSchedule() throws BusinessException;

    /**
     * 新增定时任务
     * 
     * @param scheduleJobVO
     * @throws BusinessException
     */
    @PostMapping("/add")
    void add(@RequestBody @Validated ScheduleJobVO scheduleJobVO) throws BusinessException;

    /**
     * 修改定时任务
     *
     * @param scheduleJobVO
     * @throws BusinessException
     */
    @PostMapping("/update")
    void update(@RequestBody @Validated ScheduleJobVO scheduleJobVO) throws BusinessException;

    /**
     * 取消定时任务
     * 
     * @param name
     *            任务名
     * @param group
     *            任务组
     * @throws BusinessException
     */
    @GetMapping("/cancel")
    void cancelJob(@RequestParam("name") String name, @RequestParam("group") String group) throws BusinessException;

    /**
     * 暂停定时任务
     *
     * @param name
     *            任务名
     * @param group
     *            任务组
     * @throws BusinessException
     */
    @GetMapping("/stop")
    void stopJob(@RequestParam("name") String name, @RequestParam("group") String group) throws BusinessException;

    /**
     * 恢复定时任务
     *
     * @param name
     *            任务名
     * @param group
     *            任务组
     * @throws BusinessException
     */
    @GetMapping("/restart")
    void restartJob(@RequestParam("name") String name, @RequestParam("group") String group) throws BusinessException;
}
